import type { AxiosRequestConfig, AxiosResponse } from "axios"

/* 
  希望创建出多个实例，每个实例的配置就可以不一样
  AxiosRequestConfig是不支持直接传拦截器的，直接传new时会报错
  --> 对AxiosRequestConfig类型进行拓展
*/
export interface SYInterceptor<T = AxiosResponse> {
  requestSuccessFn?: (config: AxiosRequestConfig) => AxiosRequestConfig
  requestFailureFn?: (err: any) => any
  responseSuccessFn?: (res: T) => T
  responseFailureFn?: (err: any) => any
}

export interface SYRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  interceptors?: SYInterceptor<T>
}
